import {request} from '@umijs/max';
import * as API from "@/services";


/** 期刊订阅 分页检索请求 */
export async function queryJournalSubscribes(params: API.JournalSubscribePageQueryParams): Promise<API.RespPageResult<API.JournalSubscribe>> {
  return request('/api/v1/journal-subscribe', {
    params,
  });
}

/** 期刊订阅 详情请求 */
export async function queryJournalSubscribe(bizId: API.EntityId): Promise<API.RespResult<API.JournalSubscribe>> {
  return request(`/api/v1/journal-subscribe/${bizId}`);
}

/** 期刊订阅 创建请求 */
export async function createJournalSubscribe(entity: API.JournalSubscribe_Create): Promise<API.RespResult<any>> {
  return request(`/api/v1/journal-subscribe`, {
    method: 'POST',
    data: entity,
  });
}

/** 期刊订阅 修改请求 */
export async function modifyJournalSubscribe(entity: API.JournalSubscribe_Modify): Promise<API.RespResult<any>> {
  return request(`/api/v1/journal-subscribe/${entity.id}`, {
    method: 'PUT',
    data: entity,
  });
}

/** 期刊订阅 修改(部分)请求 */
export async function patchJournalSubscribe(entity: API.JournalSubscribe_Patch): Promise<API.RespResult<any>> {
  return request(`/api/v1/journal-subscribe/${entity.id}`, {
    method: 'PATCH',
    data: entity,
  });
}

/** 期刊订阅 删除请求 */
export async function deleteJournalSubscribe(bizId: API.EntityId): Promise<API.RespResult<any>> {
  return request(`/api/v1/journal-subscribe/${bizId}`, {
    method: 'DELETE',
  });
}

/** 期刊订阅 批量删除请求 */
export async function deleteJournalSubscribes(bizIds: API.EntityId[]): Promise<API.RespResult<any>> {
  return request(`/api/v1/journal-subscribe`, {
    method: 'DELETE',
    data: {
      ids: bizIds,
    },
  });
}

/** 订阅退订请求 */
export async function unsubscribeJournal(bizId: API.EntityId): Promise<API.RespResult<boolean>> {
  return request(`/api/v1/journal-subscribe/${bizId}/unsubscribe`, {
    method: "POST",
  });
}
